package com.phone.rest.modular.bussiness.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.phone.rest.common.persistence.dao.MemberMapper;
import com.phone.rest.common.persistence.model.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.phone.rest.modular.bussiness.service.IMemberSv;
import java.util.List;

/**
 * Created by zengzr on 2017/10/20.
 */
@Service
@Transactional
public class MemberSvImpl implements IMemberSv {

    @Autowired
    private MemberMapper memberMapper;


    @Override
    public Member selectById(String openId) {
        Member m=new Member();
        m.setOpenId(openId);
        return memberMapper.selectOne(m);
    }

    @Override
    public void insert(Member newm) {
        memberMapper.insert(newm);
    }

    @Override
    public void update(Member oldm) {
        memberMapper.updateById(oldm);
    }

    @Override
    public List<Member> selectMembers(Page<Member> page, Member member) {
        EntityWrapper ew=new EntityWrapper();
        ew.setEntity(member);
        return memberMapper.selectPage(page,ew);
    }
}
